package org.dromara.learning_lhz.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.learning_lhz.entity.AsStudyPlanEntity;
import org.dromara.learning_lhz.entity.dto.StudyPlanDto;
import org.dromara.learning_lhz.entity.vo.StudyPlanVo;
import org.dromara.learning_lhz.service.StudyPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 学习计划控制器，提供对学习计划的增删改查操作接口
 */
@RestController
@RequestMapping("/studyPlan")
public class StudyPlanController {

    @Autowired
    private StudyPlanService selStudyPlan;

    /**
     * 分页查询学生学习计划
     *
     * @param studyPlanDto 包含查询条件的DTO对象
     * @return 分页结果，包含学习计划的VO列表
     */
    @GetMapping("/selStudyPlan")
    public Page<StudyPlanVo> selStudyPlan(PageQuery pageQuery,StudyPlanDto studyPlanDto) {
        return selStudyPlan.selStudyPlan(studyPlanDto,pageQuery);
    }

    /**
     * 添加学生学习计划
     *
     * @param studyPlanDto 待添加的学习计划实体对象
     */
    @PostMapping("/addStudyPlan")
    public void addStudyPlan(@RequestBody StudyPlanDto studyPlanDto) {
         selStudyPlan.addStudyPlan(studyPlanDto);
    }

    /**
     * 更新学生学习计划
     *
     * @param asStudyPlanEntity 待更新的学习计划实体对象
     */
    @PostMapping("/updateStudyPlan")
    public void updateStudyPlan(@RequestBody AsStudyPlanEntity asStudyPlanEntity) {
         selStudyPlan.updateById(asStudyPlanEntity);
    }

    /**
     * 删除学生学习计划
     *
     * @param asStudyPlanEntity 待删除的学习计划实体对象，至少包含标识ID
     */
    @PostMapping("/deleteStudyPlan")
    public void deleteStudyPlan(@RequestBody AsStudyPlanEntity asStudyPlanEntity) {
         selStudyPlan.removeById(asStudyPlanEntity);
    }

}
